# -*- coding: UTF-8 -*-

import random
import os.path
import codecs
import random


class DictionaryInfo():
    def __init__(self, file_name, description, enable_by_default):
        self.file_name = file_name
        self.description = description
        self.enable_by_default = enable_by_default

    enabled_dictionaries = {}

    @staticmethod
    def parse_dictionaries_metadata():
        path_to_meta = os.path.join(os.path.dirname(__file__),
                                    '..', 'data', 'dictionaries.meta')
        dictionary_meta_file = codecs.open(path_to_meta, encoding='utf-8',
                                           mode='r')
        dicts_list = []
        for line in dictionary_meta_file:
            if (line.strip().startswith('#')):
                continue
            line = line.strip(' ')
            (name, description, enable_by_default) = line.split(',')
            name = name.strip(' ')
            description = description.strip(' ')
            enable_by_default = enable_by_default.strip(' ')
            if (enable_by_default.lower().strip() == u'true'):
                dicts_list.append(DictionaryInfo(name, description, True))
            else:
                dicts_list.append(DictionaryInfo(name, description, False))

        dictionary_meta_file.close()
        return dicts_list
